

import request from '@/router/axios'

export function fetchList (query) {
  return request({
    url: '/admin/role/page',
    method: 'get',
    params: query
  })
}

export function fetchRoleList (tenantId) {
  return request({
    url: '/admin/role/list',
    method: 'get',
    params: {
      tenantId,
    }
  })
}

export function getObj (id) {
  return request({
    url: '/admin/role/' + id,
    method: 'get'
  })
}

export function addObj (obj) {
  return request({
    url: '/admin/role',
    method: 'post',
    data: obj
  })
}

export function putObj (obj) {
  return request({
    url: '/admin/role',
    method: 'put',
    data: obj
  })
}

export function delObj (ids) {
  return request({
    url: '/admin/role/' + ids,
    method: 'delete'
  })
}

export function permissionUpd (roleId, menuIds) {
  return request({
    url: '/admin/role/menu',
    method: 'put',
    data: {
      roleId: roleId,
      menuIds: menuIds
    }
  })
}

export function permDataRuleUpd (roleId, dataRuleIds) {
  return request({
    url: '/admin/role/dataRule',
    method: 'put',
    data: {
      roleId: roleId,
      dataRuleIds: dataRuleIds
    }
  })
}

export function fetchRoleTree (roleId) {
  return request({
    url: '/admin/menu/tree/' + roleId,
    method: 'get'
  })
}

export function fetchRoleDataRuleTree (roleId) {
  return request({
    url: '/admin/menu/dataRuleTree/' + roleId,
    method: 'get'
  })
}
